//package com.luo.ai.assistant.config;
//
//import io.micrometer.observation.ObservationRegistry;
//import org.springframework.ai.autoconfigure.vectorstore.redis.RedisVectorStoreProperties;
//import org.springframework.ai.embedding.BatchingStrategy;
//import org.springframework.ai.embedding.EmbeddingModel;
//import org.springframework.ai.vectorstore.observation.VectorStoreObservationConvention;
//import org.springframework.ai.vectorstore.redis.RedisVectorStore;
//import org.springframework.beans.factory.ObjectProvider;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import redis.clients.jedis.JedisPooled;
//
///**
// * Redis Vector配置
// *
// * @author luohq
// * @date 2025-01-20
// * @see org.springframework.ai.autoconfigure.vectorstore.redis.RedisVectorStoreAutoConfiguration
// */
//@Configuration
//public class RedisVectorConfig {
//
//    /**
//     * 自定义RedisStore
//     *
//     * @see org.springframework.ai.autoconfigure.vectorstore.redis.RedisVectorStoreAutoConfiguration#vectorStore
//     * @link <a href="https://docs.spring.io/spring-ai/reference/api/vectordbs/redis.html#_manual_configuration">https://docs.spring.io/spring-ai/reference/api/vectordbs/redis.html#_manual_configuration</a>
//     */
//    @Bean
//    public RedisVectorStore vectorStore(EmbeddingModel embeddingModel, RedisVectorStoreProperties properties,
//                                        JedisConnectionFactory jedisConnectionFactory, ObjectProvider<ObservationRegistry> observationRegistry,
//                                        ObjectProvider<VectorStoreObservationConvention> customObservationConvention,
//                                        BatchingStrategy batchingStrategy) {
//
//        JedisPooled jedisPooled = new JedisPooled(jedisConnectionFactory.getHostName(),
//                jedisConnectionFactory.getPort());
//        return RedisVectorStore.builder(jedisPooled, embeddingModel)
//                .indexName(properties.getIndex())
//                .prefix(properties.getPrefix())
//                // Optional: define metadata fields for filtering
//                .metadataFields(
//                        //知识文件ID
//                        RedisVectorStore.MetadataField.tag("fileId"),
//                        //知识文件原始名称
//                        RedisVectorStore.MetadataField.text("fileOriginalName"),
//                        //知识类型
//                        RedisVectorStore.MetadataField.tag("type"))
//                .initializeSchema(properties.isInitializeSchema())
//                .observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP))
//                .customObservationConvention(customObservationConvention.getIfAvailable(() -> null))
//                .batchingStrategy(batchingStrategy)
//                .build();
//    }
//
//}